package com.zx.idc.backend.gui.tlog;


import com.baomidou.mybatisplus.plugins.Page;
import com.zx.idc.backend.gui.common.BaseApi;
import com.zx.idc.backend.gui.common.Result;
import com.zx.idc.ds.tlog.entity.TLogAlarm;
import com.zx.idc.ds.tlog.service.ITLogAlarmService;
import com.zx.idc.ds.tlog.vo.TLogAlarmVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 告警日志表 前端控制器
 * </p>
 *
 * @author rxliuli
 * @since 2019-04-30
 */
@RestController
@RequestMapping("/api/tlogAlarm")
public class TLogAlarmController extends BaseApi {
    @Autowired
    private ITLogAlarmService itLogAlarmService;

    @GetMapping("/query-page")
    @RequiresPermissions("transaction-log:t-log-alarm")
    public Result<Page<TLogAlarmVo>> queryPage(Page<TLogAlarmVo> page, TLogAlarmVo tLogAlarmVo) {
        return success(itLogAlarmService.queryPage(page, tLogAlarmVo));
    }

    @PostMapping("/update-view-status-to-viewed/{id}")
    @RequiresPermissions("transaction-log:t-log-alarm")
    public Result<Boolean> updateViewStatusToViewed(@PathVariable("id") Integer id) {
        return success(itLogAlarmService.updateById(new TLogAlarm().setId(id).setViewStatus(TLogAlarm.VIEW_STATUS_DEALED)));
    }


    @GetMapping("not-view-total")
    public Result<Integer> notViewTotal() {
        return success(itLogAlarmService.notViewTotal());
    }
}

